package org.lzuploader.gui;

import org.eclipse.swt.widgets.Shell;

/** Lets the user easily make his program wait for a window to be closed.
 * 
 * @author Emmanuel Cron
 *
 */
public final class Sleep
{
    /** User should never instantiate this class. */
    private Sleep()
    {
        throw new UnsupportedOperationException();
    }
    
    /** Make the current window sleep until given shell is closed.
     * 
     * @param shell The shell to wait for
     */
    public static void sleepUntilDisposed (final Shell shell)
    {
        while (!shell.isDisposed())
        {
            if (shell.getDisplay().readAndDispatch() == false)
            {
                shell.getDisplay().sleep();
            }
        }
    }
}
